﻿using Microsoft.Graphics.Canvas;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 纸片人.win2dEffectControl.DataClass
{
    /// <summary>
    /// 有一个输入源的效果信息
    /// </summary>
    public abstract class EffectOneSourceData : EffectData
    {
        /// <summary>
        /// 输入源的效果信息
        /// </summary>
        public EffectData InputEffectData;

        /// <summary>
        /// 源的效果
        /// </summary>
        protected ICanvasImage Effect;
        /// <summary>
        /// 设置输入源
        /// </summary>
        /// <param name="data"></param>
        public void SetInputEffectData(EffectData data)
        {
            InputEffectData = data;
            data.AddOutputSequene(this);
            this.SetIsChanges();
        }

        /// <summary>
        /// 移除输入源
        /// </summary>
        public void RemoveInputEffect(EffectData data)
        {
            if (InputEffectData == data)
            {
                InputEffectData = null;
                this.SetIsChanges();
            }
        }

        protected ICanvasImage GetSourceEffect(CanvasDevice device,bool compression)
        {

            if (InputEffectData == null)
            {
                OriginalSize = Size = new Windows.Foundation.Size(0, 0);
                return null;
            }
            var source = InputEffectData.GetEffect(device, compression);
            if (source == null)
            {
                Multiple = 0;
                OriginalSize = Size = new Windows.Foundation.Size(0, 0);
                return null;

            }
            Multiple = InputEffectData.Multiple;
            Size = InputEffectData.Size;
            OriginalSize = InputEffectData.OriginalSize;
            return source;
        }

       
    }
}
